home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Xconq 7.1.0 / src / xconq-7.1.0 / x11 / xconq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-07  |  25.8 KB  |  756 lines  |  [TEXT/R*ch]

  1. /* Definitions for the X11 interface to Xconq.
  2.    Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996
  3.    Stanley T. Shebs.
  4.  
  5. Xconq is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.  See the file COPYING.  */
  9.  
  10. /* Default color of text and icons - 0 is for white on black, 1
  11.    is for black on white.  Should be set appropriately for the most
  12.    common monochrome display (color displays always do white on black).
  13.    This is also settable by the player, so the default is just for
  14.    convenience of the majority. */
  15.  
  16. #define BLACKONWHITE 1
  17.  
  18. #define BARGRAPHS
  19.  
  20. /* The default fonts can be altered by users, so these are just hints. */
  21.  
  22. #define TEXTFONT "fixed"
  23.  
  24. #define ICONFONT "xconq"
  25. #define STANDARD "standard"
  26.  
  27. /* Some X11 servers die if too much is written between output flushes. */
  28.  
  29. /* #define STUPIDFLUSH */
  30.  
  31. /* This is the name of a family of programs, so argv[0] inadequate. */
  32.  
  33. #define PROGRAMNAME "xconq"
  34. #define PROGRAMCLASSNAME "Xconq"
  35.  
  36. #include <X11/Xos.h>
  37. #include <X11/Xlib.h>
  38. #include <X11/Xutil.h>
  39. #include <X11/Xresource.h>
  40.  
  41. #include <X11/Intrinsic.h>
  42. #include <X11/StringDefs.h>
  43. #include <X11/Xaw/Box.h>
  44. #include <X11/Xaw/Form.h>
  45. #include <X11/Xaw/Paned.h>
  46. #include <X11/Xaw/Dialog.h>
  47. #include <X11/Xaw/Label.h>
  48. #include <X11/Xaw/Command.h>
  49. #include <X11/Xaw/Toggle.h>
  50. #include <X11/Xaw/List.h>
  51. #include <X11/Xaw/AsciiText.h>
  52. #include <X11/Xaw/Viewport.h>
  53. #include <X11/Xaw/Panner.h>
  54. #include <X11/Xaw/Porthole.h>
  55. #include <X11/Shell.h>
  56.  
  57. #include <X11/Xaw/Cardinals.h>
  58. #include <X11/Xaw/Toggle.h>
  59. #include <X11/Xaw/SmeBSB.h>
  60.  
  61. #include <math.h>
  62.  
  63. #include "imf.h"
  64. #include "ximf.h"
  65. #include "ui.h"
  66. #include "print.h"
  67.  
  68. #ifndef IMFLIB
  69. #ifdef VMS
  70. #define IMFLIB "[-.lib-x11]"
  71. #else /* not VMS */
  72. #define IMFLIB "../lib-x11"
  73. #endif /* VMS */
  74. #endif /* IMFLIB */
  75.  
  76. enum grayshade {
  77.   gray,
  78.   darkgray,
  79.   numgrays
  80. };
  81.  
  82. /* Drawing techniques that may be used. */
  83.  
  84. enum whattouse {
  85.   dontdraw,
  86.   useblocks,
  87.   usepictures,
  88.   usefontchars,
  89.   usepolygons
  90. };
  91.  
  92. /* Types of controls. */
  93.  
  94. enum controltypeenum {
  95.     LOOK = 0,
  96.     MOVE,
  97.     UNIT_MOVE,
  98.     UNIT_SHOOT,
  99.     UNIT_BUILD,
  100.     SHOW_TERRAIN,
  101.     SHOW_GRID,
  102.     SHOW_UNITS,
  103.     SHOW_NAMES,
  104.     SHOW_FEATURE_NAMES,
  105.     SHOW_FEATURE_BOUNDARIES,
  106.     SHOW_NUMBERS,
  107.     SHOW_PEOPLE,
  108.     SHOW_ELEV,
  109.     SHOW_TEMP,
  110.     SHOW_ALL,
  111.     SHOW_MORE,
  112.     COLR_UNITS,
  113.     COLR_TERR,
  114.     COLR_EMBL,
  115.     MONO_REVERSE,
  116.     ZOOM_OUT,
  117.     ZOOM_IN,
  118.     POPUP_HELP,
  119.     numcontrols
  120. };
  121.  
  122. /* Tools govern the interpretation of mouse clicks in a map view. */
  123.  
  124. enum tooltypes {
  125.   looktool,
  126.   movetool,
  127.   unitmovetool,
  128.   unitshoottool,
  129.   unitbuildtool,
  130. #ifdef DESIGNERS
  131.   cellpainttool,
  132.   bordpainttool,
  133.   connpainttool,
  134.   unitaddtool,
  135.   peoplepainttool,
  136.   featurepainttool,
  137. #endif /* DESIGNERS */
  138.   numtools
  139. };
  140.  
  141. struct a_movie {
  142.   enum movie_type type;
  143.   int args[5];
  144. };
  145.  
  146. #define N_COMMAND  3
  147. #define N_CHOICE   1
  148. #define N_BUTTON   (N_COMMAND+N_CHOICE)
  149. #define N_TOGGLE   6
  150. #define N_DIALOG  12
  151. #define N_DIMEN_D 10 
  152. #define N_WIDGET (N_BUTTON+N_TOGGLE+N_DIALOG)
  153.  
  154. /* The user interface substructure.  This is only allocated for sides with
  155.    attached displays. */
  156.  
  157. typedef struct a_ui {
  158.     Display *dpy;        /* The X display used by this side */
  159.     int active;            /* True when the display is usable */
  160.     int screen;            /* The X screen in use */
  161.     Widget shell;        /* Main shell for this side's displays */
  162.     Window rootwin;        /* The root window */
  163.     Pixel foreground;
  164.     Pixel background;
  165.     String geospec;
  166.     int mpTime;            /* # of milliseconds to pause between mplayer moves */
  167.     Atom kill_atom;
  168.     short bonw;            /* true if display is black-on-white */
  169.     short follow_action;    /* scroll to where something has occured */
  170.     int sxdown, sydown;
  171.     int    cellx, celly;
  172.     Boolean cellxy_ok;        /* cellx & celly valid? */
  173.     struct a_map *mapdown;
  174.     int beepcount;        /* number of times we've been beeped */
  175.     /* Constructed during display init. */
  176.     short monochrome;        /* obvious */
  177.     short fw, fh;        /* dimensions of text font (in pixels) */
  178.     /* Working variables for the display. */
  179.     long bgcolor;        /* background color */
  180.     long fgcolor;        /* foreground (text) color */
  181.     long whitecolor;        /* actual white for this display */
  182.     long blackcolor;        /* actual black for this display */
  183.     long enemycolor;        /* color for them (usually red) */
  184.     long neutcolor;        /* color for fencesitters (usually gray) */
  185.     long graycolor;        /* color for graying out (usually gray) */
  186.     long diffcolor;        /* unusual/distinct color (usually maroon) */
  187.     long goodcolor;        /* color for OKness (usually green) */
  188.     long badcolor;        /* color for non-OKness (usually red) */
  189.     long gridcolor;
  190.     long unseencolor;
  191.     long cellcolor[MAXTTYPES];    /* the color of each terrain type */
  192.     long cellfgcolor[MAXTTYPES]; /* the "fg" color of each terrain type */
  193.     long colors[MAXSIDES][3];
  194.     int numcolors[MAXSIDES];
  195.     long *unitcolors;
  196.     long *numunitcolors;
  197.     short dflt_color_unit_images;
  198.     short dflt_color_terr_images;
  199.     short dflt_color_embl_images;
  200.     GC gc;            /* a tmp graphics context for this display */
  201.     GC textgc;            /* foreground on background text */
  202.     GC ltextgc;            /* foreground on background text */
  203.     GC terrgc;            /* terrain display gc */
  204.     GC unitgc;            /* unit display gc */
  205.     GC emblgc;            /* emblem display gc */
  206.     GC bdrygc;            /* country/feature boundary gc */
  207.     XFontStruct *textfont;    /* Font for text display */
  208.     /* Map-related slots. */
  209.     struct a_map *maps;        /* Chain of maps that are up */
  210.     /* Help-related slots. */
  211.     Widget help_shell;
  212.     Widget help_form;
  213.     Widget help_topicPort;
  214.     Widget help_topicList;
  215.     Widget help_title;
  216.     Widget help_text;
  217.     Widget help_button_box;
  218.     Widget help_next;
  219.     Widget help_prev;
  220.     Widget help_back;
  221.     Widget help_close;
  222.     short helpw, helph;
  223.     struct a_helpnode *curhelpnode;
  224.     struct a_helpnode **nodestack;
  225.     int nodenumber, nodestackpos;
  226.     /* Printing-related slots. */
  227.     Widget print_shell;
  228.     Widget print_help_shell;
  229.     Widget print_cmds[N_WIDGET];
  230.     PrintParameters *ps_pp;
  231.     int choi[N_CHOICE];
  232.     int flag[N_TOGGLE];
  233.     double parm[N_DIALOG];
  234.     int i_metric;
  235. #ifdef DESIGNERS
  236.     /* Design-related slots. */
  237.     Widget design_shell;
  238.     Widget design;
  239.     Widget normal_button;
  240.     Widget normal_label;
  241.     Widget terrain_button;
  242.     Widget terrain_label;
  243.     Widget unit_button;
  244.     Widget unit_label;
  245.     Widget people_button;
  246.     Widget people_label;
  247.     Widget feature_button;
  248.     Widget feature_label;
  249.     Widget brush_radius_label;
  250.     short curdesigntool;
  251.     short curbrushradius;
  252.     short curttype;
  253.     short curbgttype;
  254.     short curutype;
  255.     short curusidenumber;
  256.     short cursidenumber;
  257.     short curfid;
  258. #endif /* DESIGNERS */
  259.     /* Arrays of image families for units, terrain, and sides. */
  260.     ImageFamily **uimages;
  261.     ImageFamily **timages;
  262.     ImageFamily **eimages;
  263.     /* Terrain drawing machinery */
  264.     enum whattouse usewhat[NUMPOWERS][MAXTTYPES];
  265.     /* (should use as cache of image in image family - calc as needed) */
  266.     Pixmap terrpics[NUMPOWERS][MAXTTYPES];
  267.     char terrchars[NUMPOWERS][MAXTTYPES];
  268.     XFontStruct *terrfonts[NUMPOWERS][MAXTTYPES];
  269.     Pixmap hexpics[NUMPOWERS], bhexpics[NUMPOWERS];
  270.     Pixmap hexchars[NUMPOWERS], bhexchars[NUMPOWERS];
  271.     XFontStruct *hexfonts[NUMPOWERS], *bhexfonts[NUMPOWERS];
  272.     /* Unit drawing machinery */
  273.     Pixmap unitpics[NUMPOWERS][MAXUTYPES];
  274.     Pixmap unitmasks[NUMPOWERS][MAXUTYPES];
  275.     char unitchars[NUMPOWERS][MAXUTYPES];
  276.     XFontStruct *unitfonts[NUMPOWERS][MAXUTYPES];
  277.     XFontStruct *unitfont;    /* font for unit characters */
  278.     int unitw[NUMPOWERS][MAXUTYPES], unith[NUMPOWERS][MAXUTYPES];
  279.     /* Emblem drawing machinery */
  280.     Pixmap emblempics[MAXSIDES];
  281.     Pixmap emblemmasks[MAXSIDES];
  282.     int embw[MAXSIDES], embh[MAXSIDES];
  283.     /* Map legend drawing machinery */
  284.     XFontStruct *ulegendfonts[NUMPOWERS][MAXUTYPES];
  285.     XFontStruct *flegendfonts[6];
  286.     Font flegendfids[6];
  287.     Legend *legends;
  288.     int numfeatures;
  289.     /* Side closeup list */
  290.     struct a_side_closeup *sidecloseuplist;
  291.     /* Unit list */
  292.     struct a_unit_list *unitlistlist;
  293.     /* Unit closeup list */
  294.     struct a_unit_closeup *unitcloseuplist;
  295.     /* Unit closeup summary */
  296.     struct a_closeup_summary *closeupsummary;
  297.     /* Orders interface */
  298.     Widget orders_shell;
  299.     Widget orders_label;
  300.     Widget orders_form;
  301.     Widget orders_help_shell;
  302.     StandingOrder *sorder_edit;
  303.     char *sorder_types_edit;
  304.     Task *sorder_task_edit;
  305.     struct a_order_interface *ordi_edit;
  306.     struct a_order_interface *orderlist;
  307.     int *grok_p1;
  308.     int *grok_p2;
  309.     int grok_size;
  310.     /* Random stuff */
  311.     Pixmap bombpics[4];
  312.     Pixmap hitpics[3];
  313.     Pixmap controlpics[numcontrols];
  314.     Pixmap toolcursors[numtools];
  315.     Pixmap unitcursors[MAXUTYPES];
  316.     Pixmap boxcurs, boxmask;
  317.     Pixmap grays[numgrays];
  318.     int numscheduled;
  319.     struct a_movie movies[10];
  320. } UI;
  321.  
  322. /* A closer look at a side. */
  323. typedef struct a_side_closeup {
  324.     struct a_map *map;
  325.     struct a_side *side;
  326.     Widget shell, info, *filter, list_units;
  327.     struct a_side_closeup *next;
  328. } SideCloseup;
  329.  
  330. /* A list of units. */
  331. typedef struct a_unit_list {
  332.     struct a_map *map;
  333.     int number;
  334.     Unit **units;
  335.     char **labels;
  336.     Widget shell, label, list, close;
  337.     struct a_unit_list *next;
  338. } UnitList;
  339.  
  340. /* A closer look at a unit. */
  341. typedef struct a_unit_closeup {
  342.     struct a_map *map;
  343.     struct a_unit *unit;
  344.     Widget shell, info;
  345.     struct a_unit_closeup *next;
  346. } UnitCloseup;
  347.  
  348. /* List of unit closeups */
  349. typedef struct a_closeup_summary {
  350.     int number;
  351.     UnitCloseup **unitcloseups;
  352.     char **labels;
  353.     Widget shell, label, list;
  354. } CloseupSummary;
  355.  
  356. /* Orders interface */
  357. typedef struct a_order_interface {
  358.     StandingOrder *sorder;
  359.     Widget form, toggle, types, etype, eparms, task, tparms;
  360.     Pixel form_bg, form_fg;
  361.     struct a_order_interface *next;
  362. } OrderInterface;
  363.  
  364. /* Iteration over all of a side's unit closeups. */
  365. #define for_all_unit_closeups(c,s)  \
  366.   for ((c) = (s)->ui->unitcloseuplist; (c) != NULL; (c) = (c)->next)
  367.  
  368. /* Iteration over all of a side's unit lists. */
  369. #define for_all_unit_lists(l,s)  \
  370.   for ((l) = (s)->ui->unitlistlist; (l) != NULL; (l) = (l)->next)
  371.  
  372. /* Iteration over all of a side's side closeups. */
  373. #define for_all_side_closeups(c,s)  \
  374.   for ((c) = (s)->ui->sidecloseuplist; (c) != NULL; (c) = (c)->next)
  375.  
  376. /* Each side can open up any number and shape of maps. */
  377.  
  378. /* All the maps will share colors and bitmaps though. */
  379.  
  380. typedef struct a_map {
  381.     /* Widgets that make up the map. */
  382.     Widget mainwidget;
  383.     Widget leftpane;        /* lefthand area of window */
  384.     Widget leftform;        /*  */
  385.     Widget rightpane;        /* righthand area of window */
  386.     Widget infoform;        /* parts of leftform */
  387.     Widget controlform;        /* parts of leftform */
  388.     Widget *controls;        /* Array of controls */
  389.     Widget mapform;        /* parts of leftform */
  390.     Widget sideform;        /* parts of rightform */
  391.     Widget info;        /* Info about current pos/unit */
  392.     Widget porthole;
  393.     Widget portlabel;
  394.     Widget gamedate;        /* Overall game info */
  395.     Widget gameclock;        /* overall game info */
  396.     Widget msgarea;        /* miscellaneous info related to UI */
  397.     Widget sides;        /* List of sides */
  398.     Widget history;        /* Place for notices/warnings */
  399.     Widget promptlabel;
  400.     Widget listview;
  401.     Widget listform;
  402.     Widget *list_buttons;    /* numutypes+1 of these */
  403.     Widget pannerbox;
  404.     Widget panner;
  405.     Widget help_pop;
  406.     Widget ctrlpanel_pop;    /* View control popup */
  407.     Widget ctrlpanel_shell;    /* View control popup's shell */
  408.     Widget ctrlpanel_form;
  409.     Widget *ctrlpanel_buttons;    /* Array of buttons */
  410.     /* Raw windows that we draw into directly. */
  411.     Window infowin;        /* info about a unit and/or cell */
  412.     Pixmap viewwin;        /* actual graphical display of an area */
  413.     Window sideswin;        /* list of sides */
  414.     /* panner pixmap */
  415.     Pixmap panner_pix;
  416.     /* How to draw the map. */
  417.     short seeall;        /* True if viewing world data directly */
  418.     short drawterrain;        /* Display solid color terrain on the map? */
  419.     short drawgrid;        /* Draw outlines around cells? */
  420.     short drawcellpats;        /* Draw terrain patterns? */
  421.     short drawunits;        /* Display units on the map? */
  422.     short drawnames;        /* Display unit names/numbers on the map? */
  423.     short drawfeatureboundaries;
  424.     short drawfeaturenames;    /* true if displaying names of features */
  425.     short oldesttoshow;        /* the relative time of the oldest data */
  426.     short agetofade;        /* point at which to gray out the display */
  427.     short newesttoshow;        /* the relative time of the newest data */
  428.     short fadeterrain;        /* fade world features as well as units? */
  429.     short lowestlevel;        /* the lowest level of units to display */
  430.     short highestlevel;        /* the highest level of units to display */
  431.     short drawpeople;        /* true if displaying people sides */
  432.     short drawelevations;        /* true if display elevations */
  433.     short drawresources[MAXMTYPES];
  434.     short drawtemp;
  435.     short drawweather;
  436.     short use_color_unit_images;
  437.     short use_color_terr_images;
  438.     short use_color_embl_images;
  439.     short fullpanel;
  440.     short follow_action;
  441.     /* Slots used for internal display calculations. */
  442.     VP *vp;            /* This map's generic view parameters */
  443.     short totalw, totalh;    /* Total size of window in pixels */
  444.     short leftfrac;
  445.     short leftw;
  446.     short pxw, pxh;        /* Size of map subwindow in pixels */
  447.     short toph;
  448.     short infoh;
  449.     short list1frac;
  450.     short list1w, list1h;
  451.     short list2w, list2h;
  452.     short panw, panh;
  453.     short vx, vy;        /* lower left of viewport in cell coords */
  454.     short vw, vh;        /* Boundaries of viewport in cell coords */
  455.     short vw2, vh2;        /* 1/2 (rounded down) of above values */
  456.     short sidespacing;        /* Vertical space for each side in side list */
  457.     short last_num_in_play[MAXUTYPES];
  458.     short last_num_incomplete[MAXUTYPES];
  459.     /* Interaction controls. */
  460.     short curtool;        /* Interpretation of left-mouse clicks */
  461.     short curx, cury;        /* Current spot being looked at */
  462.     struct a_unit *curunit;    /* Unit under cursor */
  463.     short savedcurx, savedcury;    /* Current spot being looked at (saved) */
  464.     struct a_unit *savedcurunit;/* Unit under cursor (saved) */
  465.     void (*modalhandler) PARAMS ((Side *side, struct a_map *map, int cancelled));
  466.     char inpch;            /* Keyboard char */
  467.     short inptype;        /* Unit type clicked in unit type list */
  468.     short prefixarg;        /* numerical prefix argument */
  469.     short argunitid;        /* is unit id, not ptr, for safety */
  470.     short tmpt;
  471.     struct a_side *argside;
  472.     short uvec[MAXUTYPES];    /* vector of allowed unit types to input */
  473.     char ustr[MAXUTYPES+1];    /* used in composing unit type hints */
  474.     short tvec[MAXTTYPES];    /* vector of allowed terrain types to input */
  475.     char tstr[MAXTTYPES+1];    /* used in composing terrain type hints */
  476.     char prompt[BUFSIZE];    /* prompt for input */
  477.     char answer[BUFSIZE];    /* string being typed in */
  478.     int tmpint;
  479.     short frombutton;        /* true if command was issued from button */
  480.     /* Link to the next map. */
  481.     struct a_map *next;
  482. } Map;
  483.  
  484. /* Iteration over all of a side's map windows. */
  485.  
  486. #define for_all_maps(s,m)  \
  487.   for ((m) = (s)->ui->maps; (m) != NULL; (m) = (m)->next)
  488.  
  489. #define num_unit_colors(s,s2,u)  \
  490.   (((s)->ui->numunitcolors)[numutypes * (s2) + (u)])
  491.  
  492. #define unit_color(s,s2,u,n)  \
  493.   (((s)->ui->numunitcolors)[3 * (numutypes * (s2) + (u)) + (n)])
  494.  
  495. /* Values shared by all displays and all sides. */
  496.  
  497. extern Widget thistoplevel;
  498. extern XtAppContext thisapp;
  499. extern int nargs;
  500. extern Arg tmpargs[];
  501.  
  502. /* Declarations of globally visible functions. */
  503.  
  504. extern int ask_unit_type PARAMS ((Side *side, Map *map, char *prompt,
  505.                  int *poss,
  506.                  void (*handler)(Side *side, Map *map,
  507.                          int cancel)));
  508. extern int ask_terrain_type PARAMS ((Side *side, Map *map, char *prompt,
  509.                     int *poss,
  510.                     void (*handler)(Side *side, Map *map,
  511.                             int cancel)));
  512. extern void ask_side PARAMS ((Side *side, Map *map, char *prompt,
  513.                  Side *dflt,
  514.                  void (*handler)(Side *side, Map *map,
  515.                          int cancel)));
  516. extern void ask_position PARAMS ((Side *side, Map *map, char *prompt,
  517.                  void (*handler)(Side *side, Map *map,
  518.                          int cancel)));
  519. extern void ask_bool PARAMS ((Side *side, Map *map, char *prompt,
  520.                  int dflt, void (*handler)(Side *side, Map *map,
  521.                                int cancel)));
  522. extern void ask_string PARAMS ((Side *side, Map *map, char *prompt, char *dflt,
  523.                    void (*handler)(Side *side, Map *map,
  524.                            int cancel)));
  525.  
  526. extern int grok_unit_type PARAMS ((Side *side, Map *map, int *typep));
  527. extern int grok_terrain_type PARAMS ((Side *side, Map *map, int *typep));
  528. extern int grok_side PARAMS ((Side *side, Map *map, Side **side2p));
  529. extern int grok_position PARAMS ((Side *side, Map *map, int *xp, int *yp));
  530. extern int grok_bool PARAMS ((Side *side, Map *map));
  531. extern int grok_string PARAMS ((Side *side, Map *map, char **strp));
  532.  
  533. extern int xform PARAMS ((Side *side, Map *map, int x, int y,
  534.              int *sxp, int *syp));
  535. extern int x_xform_unit PARAMS ((Side *side, Map *map, Unit *unit,
  536.                 int *sxp, int *syp, int *swp, int *shp));
  537. extern int x_xform_unit_self PARAMS ((Side *side, Map *map, Unit *unit,
  538.                      int *sxp, int *syp, int *swp, int *shp));
  539. extern int x_xform_occupant PARAMS ((Side *side, Map *map,
  540.                     Unit *transport, Unit *unit,
  541.                     int sx, int sy, int sw, int sh,
  542.                     int *sxp, int *syp, int *swp, int *shp));
  543. extern int x_nearest_cell PARAMS ((Side *side, Map *map, int sx, int sy,
  544.                   int *xp, int *yp));
  545. extern int x_nearest_boundary PARAMS ((Side *side, Map *map, int sx, int sy,
  546.                       int *xp, int *yp, int *dirp));
  547. extern int x_nearest_unit PARAMS ((Side *side, Map *map, int sx, int sy,
  548.                   Unit **unitp));
  549.  
  550. extern void init_x_signal_handlers PARAMS ((void));
  551.  
  552. extern void popup_game_dialog PARAMS ((void));
  553.  
  554. extern void check_player_displays PARAMS ((void));
  555. extern void init_all_displays PARAMS ((void));
  556. extern void init_redraws PARAMS ((void));
  557. extern void init_display PARAMS ((Side *side));
  558. extern void set_colors PARAMS ((Side *side));
  559. extern long request_color PARAMS ((Side *side, char *name));
  560.  
  561. extern XFontStruct *open_font PARAMS ((Side *side, char *name, char *xdefault,
  562.                       XFontStruct *altfont, char *alttype,
  563.                       Font *fid));
  564. extern Cursor make_cursor PARAMS ((Display *dpy, Window win,
  565.                   char *cursbits, char *maskbits,
  566.                   unsigned long fg, unsigned long bg,
  567.                   unsigned int x, unsigned int y));
  568.  
  569. extern void reset_color_state PARAMS ((Side *side));
  570. extern void reset_window_colors PARAMS ((Side *side, Window win));
  571.  
  572. extern void execute_command PARAMS ((Side *side, Map *map));
  573.  
  574. extern void set_current_unit PARAMS ((Side *side, Map *map, Unit *unit));
  575. extern void set_current_xy PARAMS ((Side *side, Map *map, int x, int y));
  576. extern void clear_current PARAMS ((Side *side, Map *map));
  577. extern void save_cur PARAMS ((Side *side, Map *map));
  578. extern void restore_cur PARAMS ((Side *side, Map *map));
  579.  
  580. extern Map *create_map PARAMS ((Side *side, int power, char *geospec));
  581.  
  582. extern void add_map_actions PARAMS ((void));
  583.  
  584. extern void set_tool_cursor PARAMS ((Side *side, Map *map));
  585.  
  586. extern void set_map_power PARAMS ((Side *side, Map *map, int power));
  587. extern void x_center_on_focus PARAMS ((Side *side, Map *map));
  588.  
  589. extern void handle_key_event PARAMS ((Side *side, Map *map, XEvent *evt));
  590.  
  591. extern int find_side_and_map PARAMS ((Widget w, Side **sidep, Map **mapp));
  592. extern int find_side_and_map_via_control PARAMS ((Widget w,
  593.                          Side **sidep, Map **mapp));
  594. extern int find_side_and_map_via_listform PARAMS ((Widget w,
  595.                           Side **sidep, Map **mapp));
  596. extern int find_side_and_map_via_mapform PARAMS ((Widget w,
  597.                          Side **sidep, Map **mapp));
  598. extern int find_side_and_map_via_rightform PARAMS ((Widget w,
  599.                            Side **sidep, Map **mapp));
  600. extern int find_side_and_map_via_a_toplevel PARAMS ((Widget w,
  601.                             Side **sidep, Map **mapp));
  602. extern int find_side_and_map_via_porthole PARAMS ((Widget w,
  603.                           Side **sidep, Map **mapp));
  604. extern int find_side_via_widget PARAMS ((Widget w, Side **sidep));
  605.  
  606. extern void update_controls PARAMS ((Side *side, Map *map));
  607.  
  608. extern void draw_all_maps PARAMS ((Side *side));
  609.  
  610. extern void draw_map PARAMS ((Side *side, Map *map));
  611. extern void draw_map_view PARAMS ((Side *side, Map *map));
  612. extern void destroy_map PARAMS ((Side *side, Map *map));
  613.  
  614.  
  615. extern void draw_row PARAMS ((Side *side, Map *map,
  616.                  int x0, int y0, int len, int clearit));
  617. extern void draw_unit_image PARAMS ((Side *side, Window win,
  618.                     int sx, int sy, int sw, int sh,
  619.                     int u, int s2, int fg, int bg));
  620. extern void draw_side_emblem PARAMS ((Side *side, Window win,
  621.                      int ex, int ey, int ew, int eh,
  622.                      int s2, int style));
  623. extern void draw_current PARAMS ((Side *side, Map *map));
  624. extern void erase_current PARAMS ((Side *side, Map *map, int x, int y,
  625.                   Unit *unit));
  626.  
  627. extern void draw_prompt PARAMS ((Side *side, Map *map));
  628. extern void clear_prompt PARAMS ((Side *side, Map *map));
  629. extern void draw_map_info PARAMS ((Side *side, Map *map));
  630. extern void draw_game_state PARAMS ((Side *side, Map *map));
  631. extern void draw_game_clocks PARAMS ((Side *side, Map *map));
  632. extern void draw_map_sides PARAMS ((Side *side, Map *map));
  633. extern void draw_side_info PARAMS ((Side *side, Map *map, Side *side2));
  634. extern void draw_side_progress PARAMS ((Side *side, Map *map, Side *side2));
  635.  
  636. extern void put_on_screen PARAMS ((Side *side, Map *map, int x, int y));
  637. extern int in_middle PARAMS ((Side *side, Map *map, int x, int y));
  638.  
  639. extern void move_the_selected_unit PARAMS ((Side *side, Map *map, Unit *unit,
  640.                        int sx, int sy));
  641.  
  642. extern void create_help PARAMS ((Side *side));
  643. extern void popup_help PARAMS ((Side *side));
  644. extern void popdown_help PARAMS ((Side *side));
  645.  
  646. extern void recenter PARAMS ((Side *side, Map *map, int x, int y));
  647.  
  648. extern void draw_text PARAMS ((Side *side, Window win, int x, int y,
  649.                   char *str,int color));
  650. extern void draw_fg_text PARAMS ((Side *side, Window win, int x, int y,
  651.                  char *str));
  652.  
  653. extern void textw_printf PARAMS ((const Widget w, const char *fmt, ...));
  654.  
  655. extern int font_width PARAMS ((XFontStruct *font));
  656. extern int font_height PARAMS ((XFontStruct *font));
  657.  
  658. extern void close_display PARAMS ((Side *side));
  659.  
  660. extern void exit_xconq PARAMS ((Side *side));
  661.  
  662. extern void notify_all PARAMS ((char *fmt, ...));
  663. extern void low_notify PARAMS ((Side *side, char *str));
  664. extern void redraw PARAMS ((Side *side));
  665. extern void flush_output PARAMS ((Side *side));
  666. extern void beep PARAMS ((Side *side));
  667.  
  668. extern void flush_input PARAMS ((Side *side));
  669.  
  670. extern void build_name PARAMS ((char *name, char *first, char *second));
  671.  
  672. extern void draw_view_in_panner PARAMS ((Side *side, Map *map));
  673.  
  674. extern void set_message_area PARAMS ((Map *map, char *msg));
  675.  
  676. extern void add_map_actions PARAMS ((void));
  677.  
  678. extern void update_unit_type_list PARAMS ((Side *side, Map *map, int u));
  679.  
  680. extern XawTextPosition widget_text_length PARAMS ((Widget w));
  681.  
  682. extern void move_caret_to_end PARAMS ((Widget w));
  683.  
  684. extern int popup_print_setup_dialog PARAMS ((Side *side));
  685.  
  686. void place_legends PARAMS ((Side *side));
  687.  
  688.  
  689. void enable_in_unit_type_list PARAMS ((Side *side, Map *map, int u, int flag));
  690.  
  691. extern int smallest_image PARAMS ((ImageFamily *imf, int *wp, int *hp));
  692. extern void zoom_in_out PARAMS ((Side *side, Map *map, int which));
  693.  
  694. extern int find_side_and_map_via_ctrlpanel_form PARAMS ((Widget w,
  695.                             Side **sidep,
  696.                             Map **mapp));
  697.  
  698. extern int min_w_for_unit_image;
  699. extern int min_h_for_unit_image;
  700.  
  701. extern time_t game_start_in_real_time;
  702. extern time_t turn_play_start_in_real_time;
  703.  
  704. extern void handle_map_sides_events PARAMS ((Widget w, XtPointer clientdata,
  705.                         XEvent *evt, Boolean *contdispatch));
  706. extern void handle_map_info_events PARAMS ((Widget w, XtPointer clientdata,
  707.                        XEvent *evt, Boolean *contdispatch));
  708.  
  709. extern void place_legends PARAMS ((Side *side));
  710.  
  711. extern void scroll_map_absolute PARAMS ((Side *side, Map *map, int sx, int sy));
  712. extern void scroll_map_relative PARAMS ((Side *side, Map *map, int sx, int sy));
  713.  
  714. extern void draw_blast_image PARAMS ((Side *side, Map *map, int sx, int sy, int sw, int sh, int blasttype));
  715. extern void invert_unit_subarea PARAMS ((Side *side, Map *map, int x, int y));
  716.  
  717. extern void update_help PARAMS ((Side *side));
  718.  
  719. /* Declarations of all the command functions. */
  720.  
  721. #undef DEF_CMD
  722. #define DEF_CMD(letter,name,args,FN,help) \
  723.   void FN PARAMS ((Side *side, Map *map));
  724.  
  725. #include "cmd.def"
  726.  
  727. #include "xcmd.def"
  728.  
  729. #ifdef DESIGNERS
  730. extern void create_design PARAMS ((Side *side));
  731. extern void popup_design PARAMS ((Side *side));
  732. extern void update_curttype PARAMS ((Side *side));
  733. extern void update_curutype PARAMS ((Side *side));
  734. extern void update_cursidenumber PARAMS ((Side *side));
  735. extern void update_curfeature PARAMS ((Side *side));
  736. extern void update_curbrushradius PARAMS ((Side *side));
  737. extern void set_designer_cur_from_map PARAMS ((Side *side, Map *map,
  738.                           int sx, int sy));
  739. extern void handle_designer_map_click PARAMS ((Side *side, Map *map,
  740.                           int sx, int sy));
  741. extern void popdown_design PARAMS ((Side *side));
  742. #endif /* DESIGNERS */
  743.  
  744. extern UnitCloseup *find_unit_closeup PARAMS ((Unit *unit, Side *side));
  745. extern UnitCloseup *find_unit_closeup_via_button PARAMS ((Widget w, Side *side));
  746. extern UnitCloseup *create_unit_closeup PARAMS ((Unit *unit, Side *side, Map *map));
  747. extern void draw_unit_closeup PARAMS ((UnitCloseup *unitcloseup, Side *side));
  748. extern void destroy_unit_closeup PARAMS ((UnitCloseup *unitcloseup, Side *side));
  749. extern SideCloseup *find_side_closeup PARAMS ((Side *side1, Side *side));
  750. extern SideCloseup *find_side_closeup_via_button PARAMS ((Widget w, Side *side));
  751. extern SideCloseup *create_side_closeup PARAMS ((Side *side1, Side *side, Map *map));
  752. extern void draw_side_closeup PARAMS ((SideCloseup *sidecloseup, Side *side));
  753. extern void destroy_side_closeup PARAMS ((SideCloseup *sidecloseup, Side *side));
  754. extern Pixmap get_unit_picture PARAMS ((int utype, Side *side));
  755. extern Pixmap get_side_picture PARAMS ((Side *side, Side *side1));
  756.